<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${package_name}.mapper.${table_name}Mapper">

    <resultMap id="BaseResultMap" type="${package_name}.entity.${table_name}">
	<#if model_column?exists>
        <#list model_column as model>
        <result column="${model.columnName!}" property="${model.changeColumnName?uncap_first}" />
        </#list>
    </#if>
    </resultMap>

	<sql id="Base_Column_List">
${"\t\t"}<#rt/>
		<#if model_column?exists>
        <#list model_column as model>
        <#if model_has_next>
${model.columnName!},<#rt/>
        <#else>
${model.columnName!}
        </#if>
        </#list>
    	</#if>
	</sql>
    
    <!-- 查询条件 -->
	<sql id="Example_Where_Clause">
		where 1=1
		<trim suffixOverrides=",">
			<#if model_column?exists>
			<#list model_column as model>						
			<if test="${model.changeColumnName?uncap_first} != null and ${model.changeColumnName?uncap_first} !='' ">
				and ${model.columnName!} = ${"#\{"}${model.changeColumnName?uncap_first}${"}"}
			</if>
			</#list>
			</#if>
		</trim>
	</sql>

    <insert id="save${table_name}" parameterType="${package_name}.entity.${table_name}">
		insert into om_org_member_overtime(<#rt/>
		<#if model_column?exists>
		<#list model_column as model>
		<#if model_has_next>
		<#lt/>${model.columnName!},<#rt/>
        <#else>
        <#lt/>${model.columnName!}<#rt/>
        </#if>
        </#list>
    	</#if><#lt/>)
 		values(<#rt/><#if model_column?exists>
        <#list model_column as model>
        <#if model_has_next>
        <#lt/>${"#\{"}${model.changeColumnName?uncap_first}${"}"},<#rt/>
        <#else>
        <#lt/>${"#\{"}${model.changeColumnName?uncap_first}${"}"}<#rt/>
        </#if>
        </#list>
    	</#if><#lt/>)
	</insert>
	
	<select id="query${table_name}ById" resultMap="BaseResultMap" parameterType="java.lang.String">
		select 
		<include refid="Base_Column_List" />
		from ${table_name?lower_case}
		where id = ${"#\{"}id}
	</select>
	
	<delete id="deleteById" parameterType="java.lang.String">
		delete from ${table_name?lower_case} where id = ${"#\{"}id}
	</delete>
	
	<update id="updateById" parameterType="${package_name}.entity.${table_name}">
		update ${table_name?lower_case} set 
		<trim  suffixOverrides="," >
		<#if model_column?exists>
		<#list model_column as model>
		<if test="${model.changeColumnName?uncap_first} != null  ">
			${model.columnName!} = ${"#\{"}${model.changeColumnName?uncap_first}},
		</if>
		</#list>
		</#if>
		</trim> where id=${"#\{"}id}
	</update>

</mapper>